package com.wa.mapper

import com.wa.pojo.VmInfo
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Result
import org.apache.ibatis.annotations.Results
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.type.JdbcType


@Mapper
open interface VmInfoMapper {
    @Select("<script> select",
            "id, vm_mac, vm_status, service_status, mission_id, version, ip, is_delete, create_time, ",
            "update_time, cab_id, server, vm_group_id, region, app_status, app_alarm",
            "from davm_vm_info",
            "<where>",
            "<if test='id!=null '>",
            "id= #{id}",
            "</if>",
            "<if test='vmMac!=null and vmMac!=\"\"'>",
            " and vm_mac= #{vmMac}",
            "</if>",
            "<if test='vmStatus!=null '>",
            " and vm_status= #{vmStatus}",
            "</if>",
            "<if test='serviceStatus!=null '>",
            " and service_status= #{serviceStatus}",
            "</if>",
            "<if test='missionId!=null '>",
            " and mission_id= #{missionId}",
            "</if>",
            "<if test='version!=null and version!=\"\"'>",
            " and version= #{version}",
            "</if>",
            "<if test='ip!=null and ip!=\"\"'>",
            " and ip= #{ip}",
            "</if>",
            "<if test='isDelete!=null '>",
            " and is_delete= #{isDelete}",
            "</if>",
            "<if test='createTime!=null and createTime!=\"\"'>",
            " and create_time= #{createTime}",
            "</if>",
            "<if test='updateTime!=null and updateTime!=\"\"'>",
            " and update_time= #{updateTime}",
            "</if>",
            "<if test='cabId!=null '>",
            " and cab_id= #{cabId}",
            "</if>",
            "<if test='server!=null and server!=\"\"'>",
            " and server= #{server}",
            "</if>",
            "<if test='vmGroupId!=null '>",
            " and vm_group_id= #{vmGroupId}",
            "</if>",
            "<if test='region!=null and region!=\"\"'>",
            " and region= #{region}",
            "</if>",
            "<if test='appStatus!=null and appStatus!=\"\"'>",
            " and app_status= #{appStatus}",
            "</if>",
            "<if test='appAlarm!=null and appAlarm!=\"\"'>",
            " and app_alarm= #{appAlarm}",
            "</if>",
            "</where>",
            "</script> "
    )
    @Results(Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), Result(column = "vm_mac", property = "vmMac", jdbcType = JdbcType.VARCHAR), Result(column = "vm_status", property = "vmStatus", jdbcType = JdbcType.INTEGER), Result(column = "service_status", property = "serviceStatus", jdbcType = JdbcType.INTEGER), Result(column = "mission_id", property = "missionId", jdbcType = JdbcType.INTEGER), Result(column = "version", property = "version", jdbcType = JdbcType.VARCHAR), Result(column = "ip", property = "ip", jdbcType = JdbcType.VARCHAR), Result(column = "is_delete", property = "isDelete", jdbcType = JdbcType.INTEGER), Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP), Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.TIMESTAMP), Result(column = "cab_id", property = "cabId", jdbcType = JdbcType.INTEGER), Result(column = "server", property = "server", jdbcType = JdbcType.VARCHAR), Result(column = "vm_group_id", property = "vmGroupId", jdbcType = JdbcType.INTEGER), Result(column = "region", property = "region", jdbcType = JdbcType.VARCHAR), Result(column = "app_status", property = "appStatus", jdbcType = JdbcType.VARCHAR), Result(column = "app_alarm", property = "appAlarm", jdbcType = JdbcType.VARCHAR))
    fun selectAll(record: VmInfo): List<VmInfo>
}